// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLObjectImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLAlterTableExchangePartition.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLName.h"
#include "../SQLExpr.h"
#include "SQLExprTableSource.h"
#include "../../../utils/listTran.h"

SQLAlterTableExchangePartition::SQLAlterTableExchangePartition()
{
  partitions = std::make_shared<std::list<SQLExpr_ptr>>();
}

// @Override
void SQLAlterTableExchangePartition::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterTableExchangePartition)))
  {
    SQLObject_list_ptr tmp1 = ListTran::tran_class<SQLExpr, SQLObject>(partitions);
    acceptChild(visitor, tmp1);
    acceptChild(visitor, table);
  }
  visitor->endVisit(SharedObject(SQLAlterTableExchangePartition));
}

SQLExpr_list_ptr SQLAlterTableExchangePartition::getPartitions()
{
  return partitions;
}

void SQLAlterTableExchangePartition::addPartition(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterTableExchangePartition));
  }
  this->partitions->push_back(x);
}

SQLExprTableSource_ptr SQLAlterTableExchangePartition::getTable()
{
  return table;
}

void SQLAlterTableExchangePartition::setTable(SQLName_ptr x)
{
  setTable(SQLExprTableSource_ptr(new SQLExprTableSource(x)));
}

void SQLAlterTableExchangePartition::setTable(SQLExprTableSource_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterTableExchangePartition));
  }
  this->table = x;
}

void SQLAlterTableExchangePartition::setValidation(BOOL_ptr validation)
{
  this->validation = validation;
}

BOOL_ptr SQLAlterTableExchangePartition::getValidation()
{
  return validation;
}
